package com.ruoyi.project.WxMoudle.api;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.WxMoudle.Bases.WeixinConfig;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public class WxService extends WxMpServiceImpl {

    @PostConstruct
    public void init() {
        final WxMpInMemoryConfigStorage config = new WxMpInMemoryConfigStorage();
        config.setAppId(StringUtils.trimToNull(WeixinConfig.APPID));// 设置微信公众号的appid
        config.setSecret(StringUtils.trimToNull(WeixinConfig.APPSECRET));// 设置微信公众号的app corpSecret
      /*  config.setToken(StringUtils.trimToNull(WeixinConfig.TOKEN));// 设置微信公众号的token
        config.setAesKey(StringUtils.trimToNull(WeixinConfig.AESKEY));// 设置消息加解密密钥*/
        super.setWxMpConfigStorage(config);
    }
}